[release/10.0] Pass correct search path to DllImportResolver for default flags on Mono#129862
Open
github-actions[bot] wants to merge 1 commit into
Open
[release/10.0] Pass correct search path to DllImportResolver for default flags on Mono#129862github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
When neither the P/Invoke nor the assembly has a DefaultDllImportSearchPaths attribute, Mono passed DllImportSearchPath.AssemblyDirectory to a registered DllImportResolver instead of null. lookup_pinvoke_call_impl defaults the flags to ASSEMBLY_DIRECTORY for the built-in probing logic, and netcore_resolve_with_dll_import_resolver derived "has search flags" from (flags != 0), so the defaulted value leaked to the resolver. Combined with #114756 - which made an explicit AssemblyDirectory no longer fall back to the OS search - this broke resolvers that forward the search path to NativeLibrary.Load, such as loading iOS @rpath frameworks. Thread the existing user_specified_flags signal through to the resolver so it receives the attribute value, or null when none was specified, matching CoreCLR and NativeAOT. Fixes #129798 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
AaronRobinsonMSFT
approved these changes
Jun 25, 2026
JulieLeeMSFT
approved these changes
Jun 25, 2026
This was referenced Jun 25, 2026
Member
|
@elinor-fung, please check a test failure. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #129831 to release/10.0
/cc @elinor-fung
Customer Impact
Customer reported in #129798.
On Mono, when no search flags are user-specified, the runtime ends up passing an explicit
DllImportSeachPath.AssemblyDirectoryvalue was passed to any registeredDllImportResolverinstead of null. The expected DllImportResolver contract is that search path is the attribute value, or null when neither the P/Invoke nor the assembly has the attribute.Before #114756, specifying only
DllImportSearchPath.AssemblyDirectorywould still do the default search, so the Mono behaviour of explicitly passingAssemblyDirectoryinstead of null didn't really matter. After that change, specifying onlyDllImportSeachPath.AssemblyDirectorymeant only assembly directory. This means that when a resolver that forwards the (wrongly non-null) AssemblyDirectory to NativeLibrary.Load, it no longer does the default search.This change propagates the tracking of whether flags were user-specified to the resolver invocation, so the resolver is given the attribute value or null for non-user-specified.
Fixes #129798
Regression
#114756
Testing
Automated tests added.
Risk
Low. Mono-only, propagating a boolean value correctly.